//------------------------------------------------------------------------------------------------- 
// <copyright file="PropertyBagInfo.cs" company="Collaboris">
// Copyright (c) Collaboris .  All rights reserved.
// </copyright>
//-------------------------------------------------------------------------------------------------
namespace Collaboris.Saf.Actions.Wss.Entities
{
    using System;
    using System.Xml.Serialization;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    using Utils;

    [Serializable]
    [CollaborisClass(
        Title = "Property Bag Info.",
        ReleaseStatus = ReleaseStatus.Beta,
        Summary = "Defines the parameters to add (or update) a set of property bag items in the farm, webapp, site or web.")]
    public class PropertyBagInfo : WSSEntityBase
    {
        private SerializableObjectDictionary<string> keyValuePairs;

        private SPScope? scope;

        [CollaborisProperty(
            Summary = "Specifies the key " +
                     "and object to store in the property bag.",
            Title = "Key Value Pairs",
            Example = @"<dictionary> " +
                        @"<entry key=""StringKey1"" value=""AStringValue"" />" +
                        @"<entry key=""IntKey1"">" +
                          @"<value type=""int"">3</value>" +
                        @"</entry>" +
                        @"<entry key=""ListKey1"">" +
                            @"<list element-type=""string"">" +
                              @"<value>string 1</value>" +
                              @"<value>string 2</value>" +
                            @"</list>" +
                        @"</entry>" +
                      @"</dictionary>",
            SerializedExample = @"<Dictionary type=""Collaboris.Utils.SerializableObjectDictionary`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"">
                              <item type=""System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"">
                                <key>
                                  <string>StringKey1</string>
                                </key>
                                <value>
                                  <string>AStringValue</string>
                                </value>
                              </item>
                              <item type=""System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"">
                                <key>
                                  <string>IntKey1</string>
                                </key>
                                <value>
                                  <int>3</int>
                                </value>
                              </item>
                              <item type=""System.Collections.Generic.List`1[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"">
                                <key>
                                  <string>ListKey1</string>
                                </key>
                                <value>
                                  <ArrayOfString xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
                                    <string>string 1</string>
                                    <string>string 2</string>
                                  </ArrayOfString>
                                </value>
                              </item>
                            </Dictionary>",
            Remarks = "The example illustrates how to pass in dictionary " + 
                      "containing an 'int', 'string' and generic list of type 'string'.",
            InputHint = InputHint.ObjectCollection,
            Required = true)]
        [XmlElement]
        public SerializableObjectDictionary<string> KeyValuePairs
        {
            get
            {
                return this.keyValuePairs;
            }
            set
            {
                this.keyValuePairs = value;
            }
        }

        [CollaborisProperty(
            Summary = "An SPScope specifying which property bag to target.",
            Title = "Scope",
            Example = "Web",
            InputHint = InputHint.Enum,
            Required = true)]
        [XmlElement(IsNullable = true)]
        public SPScope? Scope
        {
            get
            {
                return this.scope;
            }
            set
            {
                this.scope = value;
            }
        }
    }
}